/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jdListadoLlamadas.java
 *
 * Created on 11/02/2011, 10:07:55 PM
 */

package com.fsl.sicotec.UI;
import com.fsl.sicotec.Logica.LogLlamada;
import com.fsl.sicotec.UI.*;
import com.fsl.sicotec.comun.Entidades.Llamada;
import javax.swing.*;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;

import java.util.ArrayList;
/**
 *
 * @author User
 */
public class jdListadoLlamadas extends javax.swing.JDialog {


    private LogLlamada oLogLlamada;
    private DefaultTableModel mdlLlamada;
    private ArrayList<Llamada> lista;

    
    /** Creates new form jdListadoLlamadas */
    public jdListadoLlamadas(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setSize(790, 560);

        //Instanciando las variables
        oLogLlamada = new LogLlamada();
        lista = new ArrayList();
        mdlLlamada = (DefaultTableModel) jtLista.getModel();
        jtLista.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
        //listarLlamadas();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        btnNuevo = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        btnImprimir = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnGenerarOT = new javax.swing.JButton();
        btnCerrar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtLista = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Listado de Llamadas");

        jToolBar1.setRollover(true);

        btnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/agregar.png"))); // NOI18N
        btnNuevo.setText("Nuevo");
        btnNuevo.setFocusable(false);
        btnNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnNuevo);

        btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/editar.png"))); // NOI18N
        btnModificar.setText("Modificar");
        btnModificar.setFocusable(false);
        btnModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnModificar);

        btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/eliminar.png"))); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.setFocusable(false);
        btnEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnEliminar);

        btnImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/PrintHS.png"))); // NOI18N
        btnImprimir.setText("Imprimir");
        btnImprimir.setFocusable(false);
        btnImprimir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnImprimir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnImprimir);
        jToolBar1.add(jSeparator1);

        btnGenerarOT.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/softwareD.png"))); // NOI18N
        btnGenerarOT.setText("Generar Orden");
        btnGenerarOT.setFocusable(false);
        btnGenerarOT.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGenerarOT.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGenerarOT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenerarOTActionPerformed(evt);
            }
        });
        jToolBar1.add(btnGenerarOT);

        btnCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/fsl/sicotec/UI/Recursos/exit.png"))); // NOI18N
        btnCerrar.setText("Cerrar");
        btnCerrar.setFocusable(false);
        btnCerrar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCerrar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnCerrar);

        jtLista.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jtLista);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 790, Short.MAX_VALUE)
                .addGap(10, 10, 10))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoActionPerformed
       jdRegistroLlamada vistaLlamada = new jdRegistroLlamada(this, true);
        vistaLlamada.setLocationRelativeTo(this);
        // vista.setSize(480, 300);
        vistaLlamada.setVisible(true);
       // listarLlamadas();
}//GEN-LAST:event_btnNuevoActionPerformed


    public void listarLlamadas() {
//        oLogLlamada.mostrarLlamada();
//        int intNumReg = oLogLlamada.mostrarLlamada().size();
//        mdlLlamada.setRowCount(intNumReg);
//        //lblnreg.setText("Número de Registros : " + nregistros);
//        lista = (ArrayList<Llamada>) oLogLlamada.mostrarLlamada();
//        int i = 0;
//
//        for (Llamada objLlamada : lista) {
//            mdlLlamada.setValueAt(objLlamada.getNum_llamada(), i, 0);
//            mdlLlamada.setValueAt(objLlamada.getMotivo(), i, 1);
//            mdlLlamada.setValueAt(objLlamada.getFecha(), i, 2);
//            mdlLlamada.setValueAt(objLlamada.getHora(), i, 3);
//            mdlLlamada.setValueAt(objLlamada.getEstado(), i, 4);
//            mdlLlamada.setValueAt(objLlamada.getAccion(), i, 5);
//            mdlLlamada.setValueAt(objLlamada.getUsuario_creacion(), i, 6);
//            mdlLlamada.setValueAt(objLlamada.getFecha_creacion(), i, 7);
//            mdlLlamada.setValueAt(objLlamada.getUsuario_control(), i, 8);
//            mdlLlamada.setValueAt(objLlamada.getFecha_control(), i, 9);
//            mdlLlamada.setValueAt(objLlamada.getEstacion(), i, 10);
//            mdlLlamada.setValueAt(objLlamada.getCod_cliente(), i, 11);
//            i++;
//        }
    }







    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed
       
}//GEN-LAST:event_btnModificarActionPerformed

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        
}//GEN-LAST:event_btnEliminarActionPerformed

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        setVisible(false);
}//GEN-LAST:event_btnCerrarActionPerformed

    private void btnGenerarOTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerarOTActionPerformed
       jdListadoOrdenTrabajo vistaOT = new jdListadoOrdenTrabajo(this, true);
        vistaOT.setSize(690, 520);
        vistaOT.setLocationRelativeTo(this);
        vistaOT.setVisible(true);
    }//GEN-LAST:event_btnGenerarOTActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                jdListadoLlamadas dialog = new jdListadoLlamadas(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnGenerarOT;
    private javax.swing.JButton btnImprimir;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTable jtLista;
    // End of variables declaration//GEN-END:variables

}
